
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>TypeScript 2.6 · TypeScript Handbook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Patrick Zhong">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="TypeScript 2.5.html" />
    
    
    <link rel="prev" href="TypeScript 2.7.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../handbook/tutorials/">
            
                <a href="../handbook/tutorials/">
            
                    
                    快速上手
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../handbook/tutorials/TypeScript in 5 minutes.html">
            
                <a href="../handbook/tutorials/TypeScript in 5 minutes.html">
            
                    
                    5分钟了解TypeScript
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../handbook/tutorials/ASP.NET Core.html">
            
                <a href="../handbook/tutorials/ASP.NET Core.html">
            
                    
                    ASP.NET Core
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../handbook/tutorials/ASP.NET 4.html">
            
                <a href="../handbook/tutorials/ASP.NET 4.html">
            
                    
                    ASP.NET 4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../handbook/tutorials/Gulp.html">
            
                <a href="../handbook/tutorials/Gulp.html">
            
                    
                    Gulp
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../handbook/tutorials/Knockout.html">
            
                <a href="../handbook/tutorials/Knockout.html">
            
                    
                    Knockout.js
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../handbook/tutorials/React & Webpack.html">
            
                <a href="../handbook/tutorials/React & Webpack.html">
            
                    
                    React与webpack
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="../handbook/tutorials/React.html">
            
                <a href="../handbook/tutorials/React.html">
            
                    
                    React
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8" data-path="../handbook/tutorials/Angular 2.html">
            
                <a href="../handbook/tutorials/Angular 2.html">
            
                    
                    Angular 2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9" data-path="../handbook/tutorials/Migrating from JavaScript.html">
            
                <a href="../handbook/tutorials/Migrating from JavaScript.html">
            
                    
                    从JavaScript迁移到TypeScript
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../handbook/">
            
                <a href="../handbook/">
            
                    
                    手册
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../handbook/Basic Types.html">
            
                <a href="../handbook/Basic Types.html">
            
                    
                    基础类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../handbook/Variable Declarations.html">
            
                <a href="../handbook/Variable Declarations.html">
            
                    
                    变量声明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../handbook/Interfaces.html">
            
                <a href="../handbook/Interfaces.html">
            
                    
                    接口
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../handbook/Classes.html">
            
                <a href="../handbook/Classes.html">
            
                    
                    类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../handbook/Functions.html">
            
                <a href="../handbook/Functions.html">
            
                    
                    函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../handbook/Generics.html">
            
                <a href="../handbook/Generics.html">
            
                    
                    泛型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="../handbook/Enums.html">
            
                <a href="../handbook/Enums.html">
            
                    
                    枚举
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.8" data-path="../handbook/Type Inference.html">
            
                <a href="../handbook/Type Inference.html">
            
                    
                    类型推论
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.9" data-path="../handbook/Type Compatibility.html">
            
                <a href="../handbook/Type Compatibility.html">
            
                    
                    类型兼容性
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.10" data-path="../handbook/Advanced Types.html">
            
                <a href="../handbook/Advanced Types.html">
            
                    
                    高级类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.11" data-path="../handbook/Utilit Types.md">
            
                <span>
            
                    
                    实用工具类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.12" data-path="../handbook/Symbols.html">
            
                <a href="../handbook/Symbols.html">
            
                    
                    Symbols
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.13" data-path="../handbook/Iterators and Generators.html">
            
                <a href="../handbook/Iterators and Generators.html">
            
                    
                    Iterators 和 Generators
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.14" data-path="../handbook/Modules.html">
            
                <a href="../handbook/Modules.html">
            
                    
                    模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.15" data-path="../handbook/Namespaces.html">
            
                <a href="../handbook/Namespaces.html">
            
                    
                    命名空间
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.16" data-path="../handbook/Namespaces and Modules.html">
            
                <a href="../handbook/Namespaces and Modules.html">
            
                    
                    命名空间和模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.17" data-path="../handbook/Module Resolution.html">
            
                <a href="../handbook/Module Resolution.html">
            
                    
                    模块解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.18" data-path="../handbook/Declaration Merging.html">
            
                <a href="../handbook/Declaration Merging.html">
            
                    
                    声明合并
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.19" data-path="../handbook/Writing Definition Files.html">
            
                <a href="../handbook/Writing Definition Files.html">
            
                    
                    书写.d.ts文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.20" data-path="../handbook/JSX.html">
            
                <a href="../handbook/JSX.html">
            
                    
                    JSX
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.21" data-path="../handbook/Decorators.html">
            
                <a href="../handbook/Decorators.html">
            
                    
                    Decorators
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.22" data-path="../handbook/Mixins.html">
            
                <a href="../handbook/Mixins.html">
            
                    
                    混入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.23" data-path="../handbook/Triple-Slash Directives.html">
            
                <a href="../handbook/Triple-Slash Directives.html">
            
                    
                    三斜线指令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.24" data-path="../handbook/Type Checking JavaScript Files.html">
            
                <a href="../handbook/Type Checking JavaScript Files.html">
            
                    
                    JavaScript文件里的类型检查
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../handbook/declaration files/Introduction.html">
            
                <a href="../handbook/declaration files/Introduction.html">
            
                    
                    如何书写声明文件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../handbook/declaration files/Library Structures.html">
            
                <a href="../handbook/declaration files/Library Structures.html">
            
                    
                    结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../handbook/declaration files/Do's and Don'ts.html">
            
                <a href="../handbook/declaration files/Do's and Don'ts.html">
            
                    
                    规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../handbook/declaration files/By Example.html">
            
                <a href="../handbook/declaration files/By Example.html">
            
                    
                    举例
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../handbook/declaration files/Deep Dive.html">
            
                <a href="../handbook/declaration files/Deep Dive.html">
            
                    
                    深入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../handbook/declaration files/Publishing.html">
            
                <a href="../handbook/declaration files/Publishing.html">
            
                    
                    发布
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../handbook/declaration files/Consumption.html">
            
                <a href="../handbook/declaration files/Consumption.html">
            
                    
                    使用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../handbook/tsconfig.json.html">
            
                <a href="../handbook/tsconfig.json.html">
            
                    
                    工程配置
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../handbook/tsconfig.json.html">
            
                <a href="../handbook/tsconfig.json.html">
            
                    
                    tsconfig.json
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../handbook/Project References.html">
            
                <a href="../handbook/Project References.html">
            
                    
                    工程引用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../handbook/Typings for NPM Packages.html">
            
                <a href="../handbook/Typings for NPM Packages.html">
            
                    
                    NPM包的类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../handbook/Compiler Options.html">
            
                <a href="../handbook/Compiler Options.html">
            
                    
                    编译选项
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../handbook/Configuring Watch.html">
            
                <a href="../handbook/Configuring Watch.html">
            
                    
                    配置 Watch
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="../handbook/Compiler Options in MSBuild.html">
            
                <a href="../handbook/Compiler Options in MSBuild.html">
            
                    
                    在MSBuild里使用编译选项
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.7" data-path="../handbook/Integrating with Build Tools.html">
            
                <a href="../handbook/Integrating with Build Tools.html">
            
                    
                    与其它构建工具整合
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.8" data-path="../handbook/Nightly Builds.html">
            
                <a href="../handbook/Nightly Builds.html">
            
                    
                    使用TypeScript的每日构建版本
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../wiki/">
            
                <a href="../wiki/">
            
                    
                    Wiki
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../wiki/this-in-TypeScript.html">
            
                <a href="../wiki/this-in-TypeScript.html">
            
                    
                    TypeScript里的this
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../wiki/coding_guidelines.html">
            
                <a href="../wiki/coding_guidelines.html">
            
                    
                    编码规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../wiki/Common Errors.html">
            
                <a href="../wiki/Common Errors.html">
            
                    
                    常见编译错误
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../wiki/TypeScript-Editor-Support.html">
            
                <a href="../wiki/TypeScript-Editor-Support.html">
            
                    
                    支持TypeScript的编辑器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../wiki/Using-TypeScript-With-ASP.NET-5.html">
            
                <a href="../wiki/Using-TypeScript-With-ASP.NET-5.html">
            
                    
                    结合ASP.NET v5使用TypeScript
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../wiki/Architectural-Overview.html">
            
                <a href="../wiki/Architectural-Overview.html">
            
                    
                    架构概述
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../wiki/Roadmap.html">
            
                <a href="../wiki/Roadmap.html">
            
                    
                    发展路线图
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="./">
            
                <a href="./">
            
                    
                    新增功能
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="TypeScript 3.1.html">
            
                <a href="TypeScript 3.1.html">
            
                    
                    TypeScript 3.1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="TypeScript 3.0.html">
            
                <a href="TypeScript 3.0.html">
            
                    
                    TypeScript 3.0
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="TypeScript 2.9.html">
            
                <a href="TypeScript 2.9.html">
            
                    
                    TypeScript 2.9
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="TypeScript 2.8.html">
            
                <a href="TypeScript 2.8.html">
            
                    
                    TypeScript 2.8
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="TypeScript 2.7.html">
            
                <a href="TypeScript 2.7.html">
            
                    
                    TypeScript 2.7
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.7.6" data-path="TypeScript 2.6.html">
            
                <a href="TypeScript 2.6.html">
            
                    
                    TypeScript 2.6
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.7" data-path="TypeScript 2.5.html">
            
                <a href="TypeScript 2.5.html">
            
                    
                    TypeScript 2.5
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.8" data-path="TypeScript 2.4.html">
            
                <a href="TypeScript 2.4.html">
            
                    
                    TypeScript 2.4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.9" data-path="TypeScript 2.3.html">
            
                <a href="TypeScript 2.3.html">
            
                    
                    TypeScript 2.3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.10" data-path="TypeScript 2.2.html">
            
                <a href="TypeScript 2.2.html">
            
                    
                    TypeScript 2.2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.11" data-path="TypeScript 2.1.html">
            
                <a href="TypeScript 2.1.html">
            
                    
                    TypeScript 2.1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.12" data-path="TypeScript 2.0.html">
            
                <a href="TypeScript 2.0.html">
            
                    
                    TypeScript 2.0
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.13" data-path="TypeScript 1.8.html">
            
                <a href="TypeScript 1.8.html">
            
                    
                    TypeScript 1.8
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.14" data-path="TypeScript 1.7.html">
            
                <a href="TypeScript 1.7.html">
            
                    
                    TypeScript 1.7
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.15" data-path="TypeScript 1.6.html">
            
                <a href="TypeScript 1.6.html">
            
                    
                    TypeScript 1.6
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.16" data-path="TypeScript 1.5.html">
            
                <a href="TypeScript 1.5.html">
            
                    
                    TypeScript 1.5
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.17" data-path="TypeScript 1.4.html">
            
                <a href="TypeScript 1.4.html">
            
                    
                    TypeScript 1.4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.18" data-path="TypeScript 1.3.html">
            
                <a href="TypeScript 1.3.html">
            
                    
                    TypeScript 1.3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.19" data-path="TypeScript 1.1.html">
            
                <a href="TypeScript 1.1.html">
            
                    
                    TypeScript 1.1
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../breaking-changes/breaking-changes.html">
            
                <a href="../breaking-changes/breaking-changes.html">
            
                    
                    Breaking Changes
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../breaking-changes/TypeScript 2.4.html">
            
                <a href="../breaking-changes/TypeScript 2.4.html">
            
                    
                    TypeScript 2.4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../breaking-changes/TypeScript 2.3.html">
            
                <a href="../breaking-changes/TypeScript 2.3.html">
            
                    
                    TypeScript 2.3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../breaking-changes/TypeScript 2.2.html">
            
                <a href="../breaking-changes/TypeScript 2.2.html">
            
                    
                    TypeScript 2.2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../breaking-changes/TypeScript 2.1.html">
            
                <a href="../breaking-changes/TypeScript 2.1.html">
            
                    
                    TypeScript 2.1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.5" data-path="../breaking-changes/TypeScript 2.0.html">
            
                <a href="../breaking-changes/TypeScript 2.0.html">
            
                    
                    TypeScript 2.0
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.6" data-path="../breaking-changes/TypeScript 1.8.html">
            
                <a href="../breaking-changes/TypeScript 1.8.html">
            
                    
                    TypeScript 1.8
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.7" data-path="../breaking-changes/TypeScript 1.7.html">
            
                <a href="../breaking-changes/TypeScript 1.7.html">
            
                    
                    TypeScript 1.7
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.8" data-path="../breaking-changes/TypeScript 1.6.html">
            
                <a href="../breaking-changes/TypeScript 1.6.html">
            
                    
                    TypeScript 1.6
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.9" data-path="../breaking-changes/TypeScript 1.5.html">
            
                <a href="../breaking-changes/TypeScript 1.5.html">
            
                    
                    TypeScript 1.5
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.10" data-path="../breaking-changes/TypeScript 1.4.html">
            
                <a href="../breaking-changes/TypeScript 1.4.html">
            
                    
                    TypeScript 1.4
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >TypeScript 2.6</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="typescript-26">TypeScript 2.6</h1>
<h2 id="&#x4E25;&#x683C;&#x51FD;&#x6570;&#x7C7B;&#x578B;">&#x4E25;&#x683C;&#x51FD;&#x6570;&#x7C7B;&#x578B;</h2>
<p>TypeScript 2.6&#x5F15;&#x5165;&#x4E86;&#x65B0;&#x7684;&#x7C7B;&#x578B;&#x68C0;&#x67E5;&#x9009;&#x9879;&#xFF0C;<code>--strictFunctionTypes</code>&#x3002;<code>--strictFunctionTypes</code>&#x9009;&#x9879;&#x662F;<code>--strict</code>&#x7CFB;&#x5217;&#x9009;&#x9879;&#x4E4B;&#x4E00;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x8BF4; <code>--strict</code>&#x6A21;&#x5F0F;&#x4E0B;&#x5B83;&#x9ED8;&#x8BA4;&#x662F;&#x542F;&#x7528;&#x7684;&#x3002;&#x4F60;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x5728;&#x547D;&#x4EE4;&#x884C;&#x6216;tsconfig.json&#x4E2D;&#x8BBE;&#x7F6E;<code>--strictFunctionTypes false</code>&#x6765;&#x5355;&#x72EC;&#x7981;&#x7528;&#x5B83;&#x3002;</p>
<p><code>--strictFunctionTypes</code>&#x542F;&#x7528;&#x65F6;&#xFF0C;&#x51FD;&#x6570;&#x7C7B;&#x578B;&#x53C2;&#x6570;&#x7684;&#x68C0;&#x67E5;&#x662F;<em>&#x6297;&#x53D8;&#xFF08;contravariantly&#xFF09;</em>&#x800C;&#x975E;<em>&#x53CC;&#x53D8;&#xFF08;bivariantly&#xFF09;</em>&#x7684;&#x3002;&#x5173;&#x4E8E;&#x53D8;&#x4F53; (variance) &#x5BF9;&#x4E8E;&#x51FD;&#x6570;&#x7C7B;&#x578B;&#x610F;&#x4E49;&#x7684;&#x76F8;&#x5173;&#x80CC;&#x666F;&#xFF0C;&#x8BF7;&#x67E5;&#x770B;<a href="https://www.stephanboyer.com/post/132/what-are-covariance-and-contravariance" target="_blank">&#x534F;&#x53D8;&#xFF08;covariance&#xFF09;&#x548C;&#x6297;&#x53D8;&#xFF08;contravariance&#xFF09;&#x662F;&#x4EC0;&#x4E48;&#xFF1F;</a>&#x3002;</p>
<p>&#x8FD9;&#x4E00;&#x66F4;&#x4E25;&#x683C;&#x7684;&#x68C0;&#x67E5;&#x5E94;&#x7528;&#x4E8E;&#x9664;&#x65B9;&#x6CD5;&#x6216;&#x6784;&#x9020;&#x51FD;&#x6570;&#x58F0;&#x660E;&#x4EE5;&#x5916;&#x7684;&#x6240;&#x6709;&#x51FD;&#x6570;&#x7C7B;&#x578B;&#x3002;&#x65B9;&#x6CD5;&#x88AB;&#x4E13;&#x95E8;&#x6392;&#x9664;&#x5728;&#x5916;&#x662F;&#x4E3A;&#x4E86;&#x786E;&#x4FDD;&#x5E26;&#x6CDB;&#x578B;&#x7684;&#x7C7B;&#x548C;&#x63A5;&#x53E3;&#xFF08;&#x5982; Array<t>&#xFF09;&#x603B;&#x4F53;&#x4E0A;&#x4ECD;&#x7136;&#x4FDD;&#x6301;&#x534F;&#x53D8;&#x3002;</t></p>
<p>&#x8003;&#x8651;&#x4E0B;&#x9762;&#x8FD9;&#x4E2A; Animal &#x662F; Dog &#x548C; Cat &#x7684;&#x7236;&#x7C7B;&#x578B;&#x7684;&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">declare</span> <span class="hljs-keyword">let</span> f1: (x: Animal) =&gt; <span class="hljs-built_in">void</span>;
<span class="hljs-keyword">declare</span> <span class="hljs-keyword">let</span> f2: (x: Dog) =&gt; <span class="hljs-built_in">void</span>;
<span class="hljs-keyword">declare</span> <span class="hljs-keyword">let</span> f3: (x: Cat) =&gt; <span class="hljs-built_in">void</span>;
f1 = f2;  <span class="hljs-comment">// &#x542F;&#x7528; --strictFunctionTypes &#x65F6;&#x9519;&#x8BEF;</span>
f2 = f1;  <span class="hljs-comment">// &#x6B63;&#x786E;</span>
f2 = f3;  <span class="hljs-comment">// &#x9519;&#x8BEF;</span>
</code></pre>
<p>&#x7B2C;&#x4E00;&#x4E2A;&#x8D4B;&#x503C;&#x8BED;&#x53E5;&#x5728;&#x9ED8;&#x8BA4;&#x7684;&#x7C7B;&#x578B;&#x68C0;&#x67E5;&#x6A21;&#x5F0F;&#x4E2D;&#x662F;&#x5141;&#x8BB8;&#x7684;&#xFF0C;&#x4F46;&#x662F;&#x5728;&#x4E25;&#x683C;&#x51FD;&#x6570;&#x7C7B;&#x578B;&#x6A21;&#x5F0F;&#x4E0B;&#x4F1A;&#x88AB;&#x6807;&#x8BB0;&#x9519;&#x8BEF;&#x3002;
&#x901A;&#x4FD7;&#x5730;&#x8BB2;&#xFF0C;&#x9ED8;&#x8BA4;&#x6A21;&#x5F0F;&#x5141;&#x8BB8;&#x8FD9;&#x4E48;&#x8D4B;&#x503C;&#xFF0C;&#x56E0;&#x4E3A;&#x5B83;<em>&#x53EF;&#x80FD;&#x662F;</em>&#x5408;&#x7406;&#x7684;&#xFF0C;&#x800C;&#x4E25;&#x683C;&#x51FD;&#x6570;&#x7C7B;&#x578B;&#x6A21;&#x5F0F;&#x5C06;&#x5B83;&#x6807;&#x8BB0;&#x4E3A;&#x9519;&#x8BEF;&#xFF0C;&#x56E0;&#x4E3A;&#x5B83;&#x4E0D;&#x80FD;<em>&#x88AB;&#x8BC1;&#x660E;</em>&#x5408;&#x7406;&#x3002;
&#x4EFB;&#x4F55;&#x4E00;&#x79CD;&#x6A21;&#x5F0F;&#x4E2D;&#xFF0C;&#x7B2C;&#x4E09;&#x4E2A;&#x8D4B;&#x503C;&#x90FD;&#x662F;&#x9519;&#x8BEF;&#x7684;&#xFF0C;&#x56E0;&#x4E3A;&#x5B83;<em>&#x6C38;&#x8FDC;&#x4E0D;</em>&#x5408;&#x7406;&#x3002;</p>
<p>&#x7528;&#x53E6;&#x4E00;&#x79CD;&#x65B9;&#x5F0F;&#x6765;&#x63CF;&#x8FF0;&#x8FD9;&#x4E2A;&#x4F8B;&#x5B50;&#x5219;&#x662F;&#xFF0C;&#x9ED8;&#x8BA4;&#x7C7B;&#x578B;&#x68C0;&#x67E5;&#x6A21;&#x5F0F;&#x4E2D;<code>T</code>&#x5728;&#x7C7B;&#x578B;<code>(x: T) =&gt; void</code>&#x662F;<em>&#x53CC;&#x53D8;&#x7684;</em>&#xFF08;&#x4E5F;&#x5373;&#x534F;&#x53D8;<em>&#x6216;</em>&#x6297;&#x53D8;&#xFF09;&#xFF0C;&#x4F46;&#x5728;&#x4E25;&#x683C;&#x51FD;&#x6570;&#x7C7B;&#x578B;&#x6A21;&#x5F0F;&#x4E2D;<code>T</code>&#x662F;<em>&#x6297;&#x53D8;</em>&#x7684;&#x3002;</p>
<h5 id="&#x4F8B;&#x5B50;">&#x4F8B;&#x5B50;</h5>
<pre><code class="lang-ts"><span class="hljs-keyword">interface</span> Comparer&lt;T&gt; {
    compare: (a: T, b: T) =&gt; <span class="hljs-built_in">number</span>;
}

<span class="hljs-keyword">declare</span> <span class="hljs-keyword">let</span> animalComparer: Comparer&lt;Animal&gt;;
<span class="hljs-keyword">declare</span> <span class="hljs-keyword">let</span> dogComparer: Comparer&lt;Dog&gt;;

animalComparer = dogComparer;  <span class="hljs-comment">// &#x9519;&#x8BEF;</span>
dogComparer = animalComparer;  <span class="hljs-comment">// &#x6B63;&#x786E;</span>
</code></pre>
<p>&#x73B0;&#x5728;&#x7B2C;&#x4E00;&#x4E2A;&#x8D4B;&#x503C;&#x662F;&#x9519;&#x8BEF;&#x7684;&#x3002;&#x66F4;&#x660E;&#x786E;&#x5730;&#x8BF4;&#xFF0C;<code>Comparer&lt;T&gt;</code>&#x4E2D;&#x7684;<code>T</code>&#x56E0;&#x4E3A;&#x4EC5;&#x5728;&#x51FD;&#x6570;&#x7C7B;&#x578B;&#x53C2;&#x6570;&#x7684;&#x4F4D;&#x7F6E;&#x88AB;&#x4F7F;&#x7528;&#xFF0C;&#x662F;&#x6297;&#x53D8;&#x7684;&#x3002;</p>
<p>&#x53E6;&#x5916;&#xFF0C;&#x6CE8;&#x610F;&#x5C3D;&#x7BA1;&#x6709;&#x7684;&#x8BED;&#x8A00;&#xFF08;&#x6BD4;&#x5982;C#&#x548C;Scala&#xFF09;&#x8981;&#x6C42;&#x53D8;&#x4F53;&#x6807;&#x6CE8;&#xFF08;variance annotations&#xFF09;&#xFF08;<code>out</code>/<code>in</code> &#x6216; <code>+</code>/<code>-</code>&#xFF09;&#xFF0C;&#x800C;&#x7531;&#x4E8E;TypeScript&#x7684;&#x7ED3;&#x6784;&#x5316;&#x7C7B;&#x578B;&#x7CFB;&#x7EDF;&#xFF0C;&#x5B83;&#x7684;&#x53D8;&#x4F53;&#x662F;&#x7531;&#x6CDB;&#x578B;&#x4E2D;&#x7684;&#x7C7B;&#x578B;&#x53C2;&#x6570;&#x7684;&#x5B9E;&#x9645;&#x4F7F;&#x7528;&#x81EA;&#x7136;&#x5F97;&#x51FA;&#x7684;&#x3002;</p>
<h5 id="&#x6CE8;&#x610F;&#xFF1A;">&#x6CE8;&#x610F;&#xFF1A;</h5>
<p>&#x542F;&#x7528;<code>--strictFunctionTypes</code>&#x65F6;&#xFF0C;&#x5982;&#x679C;<code>compare</code>&#x88AB;&#x58F0;&#x660E;&#x4E3A;&#x65B9;&#x6CD5;&#xFF0C;&#x5219;&#x7B2C;&#x4E00;&#x4E2A;&#x8D4B;&#x503C;&#x4F9D;&#x7136;&#x662F;&#x88AB;&#x5141;&#x8BB8;&#x7684;&#x3002;
&#x66F4;&#x660E;&#x786E;&#x7684;&#x8BF4;&#xFF0C;<code>Comparer&lt;T&gt;</code>&#x4E2D;&#x7684;<code>T</code>&#x56E0;&#x4E3A;&#x4EC5;&#x5728;&#x65B9;&#x6CD5;&#x53C2;&#x6570;&#x7684;&#x4F4D;&#x7F6E;&#x88AB;&#x4F7F;&#x7528;&#x6240;&#x4EE5;&#x662F;&#x53CC;&#x53D8;&#x7684;&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">interface</span> Comparer&lt;T&gt; {
    compare(a: T, b: T): <span class="hljs-built_in">number</span>;
}

<span class="hljs-keyword">declare</span> <span class="hljs-keyword">let</span> animalComparer: Comparer&lt;Animal&gt;;
<span class="hljs-keyword">declare</span> <span class="hljs-keyword">let</span> dogComparer: Comparer&lt;Dog&gt;;

animalComparer = dogComparer;  <span class="hljs-comment">// &#x6B63;&#x786E;&#xFF0C;&#x56E0;&#x4E3A;&#x53CC;&#x53D8;</span>
dogComparer = animalComparer;  <span class="hljs-comment">// &#x6B63;&#x786E;</span>
</code></pre>
<p>TypeScript 2.6 &#x8FD8;&#x6539;&#x8FDB;&#x4E86;&#x4E0E;&#x6297;&#x53D8;&#x4F4D;&#x7F6E;&#x76F8;&#x5173;&#x7684;&#x7C7B;&#x578B;&#x63A8;&#x5BFC;&#xFF1A;</p>
<pre><code class="lang-ts">function combine&lt;T&gt;(...funcs: ((x: &#xFF09;=&gt; void)[]): (x: T) =&gt; void {
    return x =&gt; {
        for (const f of funcs) f(x);
    }
}

function animalFunc(x: Animal) {}
function dogFunc(x: Dog) {}

let combined = combine(animalFunc&#xFF0C;dogFunc);  // (x: Dog) =&gt; void
</code></pre>
<p>&#x8FD9;&#x4E0A;&#x9762;&#x6240;&#x6709;<code>T</code>&#x7684;&#x63A8;&#x65AD;&#x90FD;&#x6765;&#x81EA;&#x6297;&#x53D8;&#x7684;&#x4F4D;&#x7F6E;&#xFF0C;&#x7531;&#x6B64;&#x6211;&#x4EEC;&#x5F97;&#x51FA;<code>T</code>&#x7684;<em>&#x6700;&#x666E;&#x904D;&#x5B50;&#x7C7B;&#x578B;</em>&#x3002;
&#x8FD9;&#x4E0E;&#x4ECE;&#x534F;&#x53D8;&#x4F4D;&#x7F6E;&#x63A8;&#x5BFC;&#x51FA;&#x7684;&#x7ED3;&#x679C;&#x6070;&#x6070;&#x76F8;&#x53CD;&#xFF0C;&#x4ECE;&#x534F;&#x53D8;&#x4F4D;&#x7F6E;&#x6211;&#x4EEC;&#x5F97;&#x51FA;&#x7684;&#x662F;<em>&#x6700;&#x666E;&#x904D;&#x8D85;&#x7C7B;&#x578B;</em>&#x3002;</p>
<h2 id="&#x7F13;&#x5B58;&#x6A21;&#x5757;&#x4E2D;&#x7684;&#x6807;&#x7B7E;&#x6A21;&#x677F;&#x5BF9;&#x8C61;">&#x7F13;&#x5B58;&#x6A21;&#x5757;&#x4E2D;&#x7684;&#x6807;&#x7B7E;&#x6A21;&#x677F;&#x5BF9;&#x8C61;</h2>
<p>TypeScript 2.6&#x4FEE;&#x590D;&#x4E86;&#x6807;&#x7B7E;&#x5B57;&#x7B26;&#x4E32;&#x6A21;&#x677F;&#x7684;&#x8F93;&#x51FA;&#xFF0C;&#x4EE5;&#x66F4;&#x597D;&#x5730;&#x9075;&#x5FAA;ECMAScript&#x6807;&#x51C6;&#x3002;
&#x6839;&#x636E;<a href="https://tc39.github.io/ecma262/#sec-gettemplateobject" target="_blank">ECMAScript &#x6807;&#x51C6;</a>&#xFF0C;&#x6BCF;&#x4E00;&#x6B21;&#x83B7;&#x53D6;&#x6A21;&#x677F;&#x6807;&#x7B7E;&#x7684;&#x503C;&#x65F6;&#xFF0C;&#x5E94;&#x8BE5;&#x5C06;<em>&#x540C;&#x4E00;&#x4E2A;</em>&#x6A21;&#x677F;&#x5B57;&#x7B26;&#x4E32;&#x6570;&#x7EC4;&#x5BF9;&#x8C61; (&#x540C;&#x4E00;&#x4E2A; <code>TemplateStringArray</code>) &#x4F5C;&#x4E3A;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x4F20;&#x9012;&#x3002;
&#x5728; TypeScript 2.6 &#x4E4B;&#x524D;&#xFF0C;&#x6BCF;&#x4E00;&#x6B21;&#x751F;&#x6210;&#x7684;&#x90FD;&#x662F;&#x5168;&#x65B0;&#x7684;&#x6A21;&#x677F;&#x5BF9;&#x8C61;&#x3002;
&#x867D;&#x7136;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x5185;&#x5BB9;&#x662F;&#x4E00;&#x6837;&#x7684;&#xFF0C;&#x8FD9;&#x6837;&#x7684;&#x8F93;&#x51FA;&#x4F1A;&#x5F71;&#x54CD;&#x901A;&#x8FC7;&#x8BC6;&#x522B;&#x5B57;&#x7B26;&#x4E32;&#x6765;&#x5B9E;&#x73B0;&#x7F13;&#x5B58;&#x5931;&#x6548;&#x7684;&#x5E93;&#xFF0C;&#x6BD4;&#x5982; <a href="https://github.com/PolymerLabs/lit-html/issues/58" target="_blank">lit-html</a>&#x3002;</p>
<h5 id="&#x4F8B;&#x5B50;">&#x4F8B;&#x5B50;</h5>
<pre><code class="lang-ts"><span class="hljs-keyword">export</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">id</span>(<span class="hljs-params">x: TemplateStringsArray</span>) </span>{
    <span class="hljs-keyword">return</span> x;
}

<span class="hljs-keyword">export</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">templateObjectFactory</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">return</span> id<span class="hljs-string">`hello world`</span>;
}

<span class="hljs-keyword">let</span> result = templateObjectFactory() === templateObjectFactory(); <span class="hljs-comment">// TS 2.6 &#x4E3A; true</span>
</code></pre>
<p>&#x7F16;&#x8BD1;&#x540E;&#x7684;&#x4EE3;&#x7801;&#xFF1A;</p>
<pre><code class="lang-js"><span class="hljs-meta">&quot;use strict&quot;</span>;
<span class="hljs-keyword">var</span> __makeTemplateObject = (<span class="hljs-keyword">this</span> &amp;&amp; <span class="hljs-keyword">this</span>.__makeTemplateObject) || <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">cooked, raw</span>) </span>{
    <span class="hljs-keyword">if</span> (<span class="hljs-built_in">Object</span>.defineProperty) { <span class="hljs-built_in">Object</span>.defineProperty(cooked, <span class="hljs-string">&quot;raw&quot;</span>, { value: raw }); } <span class="hljs-keyword">else</span> { cooked.raw = raw; }
    <span class="hljs-keyword">return</span> cooked;
};

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">id</span>(<span class="hljs-params">x</span>) </span>{
    <span class="hljs-keyword">return</span> x;
}

<span class="hljs-keyword">var</span> _a;
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">templateObjectFactory</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">return</span> id(_a || (_a = __makeTemplateObject([<span class="hljs-string">&quot;hello world&quot;</span>], [<span class="hljs-string">&quot;hello world&quot;</span>])));
}

<span class="hljs-keyword">var</span> result = templateObjectFactory() === templateObjectFactory();
</code></pre>
<blockquote>
<p>&#x6CE8;&#x610F;&#xFF1A;&#x8FD9;&#x4E00;&#x6539;&#x53D8;&#x5F15;&#x5165;&#x4E86;&#x65B0;&#x7684;&#x5DE5;&#x5177;&#x51FD;&#x6570;&#xFF0C;<code>__makeTemplateObject</code>;
&#x5982;&#x679C;&#x4F60;&#x5728;&#x642D;&#x914D;&#x4F7F;&#x7528;<code>--importHelpers</code>&#x548C;<a href="https://github.com/Microsoft/tslib" target="_blank"><code>tslib</code></a>&#xFF0C;&#x9700;&#x8981;&#x66F4;&#x65B0;&#x5230; 1.8 &#x6216;&#x66F4;&#x9AD8;&#x7248;&#x672C;&#x3002;</p>
</blockquote>
<h2 id="&#x672C;&#x5730;&#x5316;&#x7684;&#x547D;&#x4EE4;&#x884C;&#x8BCA;&#x65AD;&#x6D88;&#x606F;">&#x672C;&#x5730;&#x5316;&#x7684;&#x547D;&#x4EE4;&#x884C;&#x8BCA;&#x65AD;&#x6D88;&#x606F;</h2>
<p>TypeScript 2.6 npm&#x5305;&#x52A0;&#x5165;&#x4E86;13&#x79CD;&#x8BED;&#x8A00;&#x7684;&#x8BCA;&#x65AD;&#x6D88;&#x606F;&#x672C;&#x5730;&#x5316;&#x7248;&#x672C;&#x3002;
&#x547D;&#x4EE4;&#x884C;&#x4E2D;&#x672C;&#x5730;&#x5316;&#x6D88;&#x606F;&#x4F1A;&#x5728;&#x4F7F;&#x7528;<code>--locale</code>&#x9009;&#x9879;&#x65F6;&#x663E;&#x793A;&#x3002;</p>
<h5 id="&#x4F8B;&#x5B50;">&#x4F8B;&#x5B50;</h5>
<p>&#x4FC4;&#x8BED;&#x663E;&#x793A;&#x7684;&#x9519;&#x8BEF;&#x6D88;&#x606F;&#xFF1A;</p>
<pre><code class="lang-sh">c:\ts&gt;tsc --v
Version 2.6.1

c:\ts&gt;tsc --locale ru --pretty c:\<span class="hljs-built_in">test</span>\a.ts

../<span class="hljs-built_in">test</span>/a.ts(1,5): error TS2322: &#x422;&#x438;&#x43F; <span class="hljs-string">&quot;&quot;</span>string<span class="hljs-string">&quot;&quot;</span> &#x43D;&#x435; &#x43C;&#x43E;&#x436;&#x435;&#x442; &#x431;&#x44B;&#x442;&#x44C; &#x43D;&#x430;&#x437;&#x43D;&#x430;&#x447;&#x435;&#x43D; &#x434;&#x43B;&#x44F; &#x442;&#x438;&#x43F;&#x430; <span class="hljs-string">&quot;number&quot;</span>.

1 var x: number = <span class="hljs-string">&quot;string&quot;</span>;
      ~
</code></pre>
<p>&#x4E2D;&#x6587;&#x663E;&#x793A;&#x7684;&#x5E2E;&#x52A9;&#x4FE1;&#x606F;&#xFF1A;</p>
<pre><code class="lang-sh">PS C:\ts&gt; tsc --v
Version 2.6.1

PS C:\ts&gt; tsc --locale zh-cn
&#x7248;&#x672C; 2.6.1
&#x8BED;&#x6CD5;&#xFF1A;tsc [&#x9009;&#x9879;] [&#x6587;&#x4EF6; ...]

&#x793A;&#x4F8B;&#xFF1A;tsc hello.ts
    tsc --outFile file.js file.ts
    tsc @args.txt

&#x9009;&#x9879;&#xFF1A;
 -h, --help                    &#x6253;&#x5370;&#x6B64;&#x6D88;&#x606F;&#x3002;
 --all                         &#x663E;&#x793A;&#x6240;&#x6709;&#x7F16;&#x8BD1;&#x5668;&#x9009;&#x9879;&#x3002;
 -v, --version                 &#x6253;&#x5370;&#x7F16;&#x8BD1;&#x5668;&#x7684;&#x7248;&#x672C;&#x3002;
 --init                        &#x521D;&#x59CB;&#x5316; TypeScript &#x9879;&#x76EE;&#x5E76;&#x521B;&#x5EFA; tsconfig.json &#x6587;&#x4EF6;&#x3002;
 -p &#x6587;&#x4EF6;&#x6216;&#x76EE;&#x5F55;, --project &#x6587;&#x4EF6;&#x6216;&#x76EE;&#x5F55;     &#x7F16;&#x8BD1;&#x7ED9;&#x5B9A;&#x4E86;&#x5176;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x8DEF;&#x5F84;&#x6216;&#x5E26; <span class="hljs-string">&quot;tsconfig.json&quot;</span> &#x7684;&#x6587;&#x4EF6;&#x5939;&#x8DEF;&#x5F84;&#x7684;&#x9879;&#x76EE;&#x3002;
 --pretty                      &#x4F7F;&#x7528;&#x989C;&#x8272;&#x548C;&#x4E0A;&#x4E0B;&#x6587;&#x98CE;&#x683C;&#x5316;&#x9519;&#x8BEF;&#x548C;&#x6D88;&#x606F;(&#x5B9E;&#x9A8C;)&#x3002;
 -w, --watch                   &#x76D1;&#x89C6;&#x8F93;&#x5165;&#x6587;&#x4EF6;&#x3002;
 -t &#x7248;&#x672C;, --target &#x7248;&#x672C;            &#x6307;&#x5B9A; ECMAScript &#x76EE;&#x6807;&#x7248;&#x672C;&#xFF1A;<span class="hljs-string">&quot;ES3&quot;</span>(&#x9ED8;&#x8BA4;)&#x3001;<span class="hljs-string">&quot;ES5&quot;</span>&#x3001;<span class="hljs-string">&quot;ES2015&quot;</span>&#x3001;<span class="hljs-string">&quot;ES2016&quot;</span>&#x3001;<span class="hljs-string">&quot;ES2017&quot;</span> &#x6216; <span class="hljs-string">&quot;ESNEXT&quot;</span>&#x3002;
 -m &#x79CD;&#x7C7B;, --module &#x79CD;&#x7C7B;            &#x6307;&#x5B9A;&#x6A21;&#x5757;&#x4EE3;&#x7801;&#x751F;&#x6210;&#xFF1A;<span class="hljs-string">&quot;none&quot;</span>&#x3001;<span class="hljs-string">&quot;commonjs&quot;</span>&#x3001;<span class="hljs-string">&quot;amd&quot;</span>&#x3001;<span class="hljs-string">&quot;system&quot;</span>&#x3001;<span class="hljs-string">&quot;umd&quot;</span>&#x3001;<span class="hljs-string">&quot;es2015&quot;</span>&#x6216; <span class="hljs-string">&quot;ESNext&quot;</span>&#x3002;
 --lib                         &#x6307;&#x5B9A;&#x8981;&#x5728;&#x7F16;&#x8BD1;&#x4E2D;&#x5305;&#x62EC;&#x7684;&#x5E93;&#x6587;&#x4EF6;:
                                 <span class="hljs-string">&apos;es5&apos;</span> <span class="hljs-string">&apos;es6&apos;</span> <span class="hljs-string">&apos;es2015&apos;</span> <span class="hljs-string">&apos;es7&apos;</span> <span class="hljs-string">&apos;es2016&apos;</span> <span class="hljs-string">&apos;es2017&apos;</span> <span class="hljs-string">&apos;esnext&apos;</span> <span class="hljs-string">&apos;dom&apos;</span> <span class="hljs-string">&apos;dom.iterable&apos;</span> <span class="hljs-string">&apos;webworker&apos;</span> <span class="hljs-string">&apos;scripthost&apos;</span> <span class="hljs-string">&apos;es2015.core&apos;</span> <span class="hljs-string">&apos;es2015.collection&apos;</span> <span class="hljs-string">&apos;es2015.generator&apos;</span> <span class="hljs-string">&apos;es2015.iterable&apos;</span> <span class="hljs-string">&apos;es2015.promise&apos;</span> <span class="hljs-string">&apos;es2015.proxy&apos;</span> <span class="hljs-string">&apos;es2015.reflect&apos;</span> <span class="hljs-string">&apos;es2015.symbol&apos;</span> <span class="hljs-string">&apos;es2015.symbol.wellknown&apos;</span> <span class="hljs-string">&apos;es2016.array.include&apos;</span> <span class="hljs-string">&apos;es2017.object&apos;</span> <span class="hljs-string">&apos;es2017.sharedmemory&apos;</span> <span class="hljs-string">&apos;es2017.string&apos;</span> <span class="hljs-string">&apos;es2017.intl&apos;</span> <span class="hljs-string">&apos;esnext.asynciterable&apos;</span>
 --allowJs                     &#x5141;&#x8BB8;&#x7F16;&#x8BD1; JavaScript &#x6587;&#x4EF6;&#x3002;
 --jsx &#x79CD;&#x7C7B;                      &#x6307;&#x5B9A; JSX &#x4EE3;&#x7801;&#x751F;&#x6210;&#xFF1A;<span class="hljs-string">&quot;preserve&quot;</span>&#x3001;<span class="hljs-string">&quot;react-native&quot;</span> &#x6216; <span class="hljs-string">&quot;react&quot;</span>&#x3002; <span class="hljs-_">-d</span>, --declaration             &#x751F;&#x6210;&#x76F8;&#x5E94;&#x7684; <span class="hljs-string">&quot;.d.ts&quot;</span> &#x6587;&#x4EF6;&#x3002;
 --sourceMap                   &#x751F;&#x6210;&#x76F8;&#x5E94;&#x7684; <span class="hljs-string">&quot;.map&quot;</span> &#x6587;&#x4EF6;&#x3002;
 --outFile &#x6587;&#x4EF6;                  &#x8FDE;&#x63A5;&#x8F93;&#x51FA;&#x5E76;&#x5C06;&#x5176;&#x53D1;&#x51FA;&#x5230;&#x5355;&#x4E2A;&#x6587;&#x4EF6;&#x3002;
 --outDir &#x76EE;&#x5F55;                   &#x5C06;&#x8F93;&#x51FA;&#x7ED3;&#x6784;&#x91CD;&#x5B9A;&#x5411;&#x5230;&#x76EE;&#x5F55;&#x3002;
 --removeComments              &#x8BF7;&#x52FF;&#x5C06;&#x6CE8;&#x91CA;&#x53D1;&#x51FA;&#x5230;&#x8F93;&#x51FA;&#x3002;
 --noEmit                      &#x8BF7;&#x52FF;&#x53D1;&#x51FA;&#x8F93;&#x51FA;&#x3002;
 --strict                      &#x542F;&#x7528;&#x6240;&#x6709;&#x4E25;&#x683C;&#x7C7B;&#x578B;&#x68C0;&#x67E5;&#x9009;&#x9879;&#x3002;
 --noImplicitAny               &#x5BF9;&#x5177;&#x6709;&#x9690;&#x5F0F; <span class="hljs-string">&quot;any&quot;</span> &#x7C7B;&#x578B;&#x7684;&#x8868;&#x8FBE;&#x5F0F;&#x548C;&#x58F0;&#x660E;&#x5F15;&#x53D1;&#x9519;&#x8BEF;&#x3002;
 --strictNullChecks            &#x542F;&#x7528;&#x4E25;&#x683C;&#x7684; NULL &#x68C0;&#x67E5;&#x3002;
 --strictFunctionTypes         &#x5BF9;&#x51FD;&#x6570;&#x7C7B;&#x578B;&#x542F;&#x7528;&#x4E25;&#x683C;&#x68C0;&#x67E5;&#x3002;
 --noImplicitThis              &#x5728;&#x5E26;&#x9690;&#x5F0F;<span class="hljs-string">&quot;any&quot;</span> &#x7C7B;&#x578B;&#x7684; <span class="hljs-string">&quot;this&quot;</span> &#x8868;&#x8FBE;&#x5F0F;&#x4E0A;&#x5F15;&#x53D1;&#x9519;&#x8BEF;&#x3002;
 --alwaysStrict                &#x4EE5;&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x8FDB;&#x884C;&#x5206;&#x6790;&#xFF0C;&#x5E76;&#x4E3A;&#x6BCF;&#x4E2A;&#x6E90;&#x6587;&#x4EF6;&#x53D1;&#x51FA; <span class="hljs-string">&quot;use strict&quot;</span> &#x6307;&#x4EE4;&#x3002;
 --noUnusedLocals              &#x62A5;&#x544A;&#x672A;&#x4F7F;&#x7528;&#x7684;&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#x4E0A;&#x7684;&#x9519;&#x8BEF;&#x3002;
 --noUnusedParameters          &#x62A5;&#x544A;&#x672A;&#x4F7F;&#x7528;&#x7684;&#x53C2;&#x6570;&#x4E0A;&#x7684;&#x9519;&#x8BEF;&#x3002;
 --noImplicitReturns           &#x5728;&#x51FD;&#x6570;&#x4E2D;&#x7684;&#x6240;&#x6709;&#x4EE3;&#x7801;&#x8DEF;&#x5F84;&#x5E76;&#x975E;&#x90FD;&#x8FD4;&#x56DE;&#x503C;&#x65F6;&#x62A5;&#x544A;&#x9519;&#x8BEF;&#x3002;
 --noFallthroughCasesInSwitch  &#x62A5;&#x544A; switch &#x8BED;&#x53E5;&#x4E2D;&#x9047;&#x5230; fallthrough &#x60C5;&#x51B5;&#x7684;&#x9519;&#x8BEF;&#x3002;
 --types                       &#x8981;&#x5305;&#x542B;&#x5728;&#x7F16;&#x8BD1;&#x4E2D;&#x7C7B;&#x578B;&#x58F0;&#x660E;&#x6587;&#x4EF6;&#x3002;
 @&lt;&#x6587;&#x4EF6;&gt;                         &#x4ECE;&#x6587;&#x4EF6;&#x63D2;&#x5165;&#x547D;&#x4EE4;&#x884C;&#x9009;&#x9879;&#x548C;&#x6587;&#x4EF6;&#x3002;
</code></pre>
<h2 id="&#x901A;&#x8FC7;--ts-ignore-&#x6CE8;&#x91CA;&#x9690;&#x85CF;-ts-&#x6587;&#x4EF6;&#x4E2D;&#x7684;&#x9519;&#x8BEF;">&#x901A;&#x8FC7; &apos;// @ts-ignore&apos; &#x6CE8;&#x91CA;&#x9690;&#x85CF; .ts &#x6587;&#x4EF6;&#x4E2D;&#x7684;&#x9519;&#x8BEF;</h2>
<p>TypeScript 2.6&#x652F;&#x6301;&#x5728;.ts&#x6587;&#x4EF6;&#x4E2D;&#x901A;&#x8FC7;&#x5728;&#x62A5;&#x9519;&#x4E00;&#x884C;&#x4E0A;&#x65B9;&#x4F7F;&#x7528;<code>// @ts-ignore</code>&#x6765;&#x5FFD;&#x7565;&#x9519;&#x8BEF;&#x3002;</p>
<h5 id="&#x4F8B;&#x5B50;">&#x4F8B;&#x5B50;</h5>
<pre><code class="lang-ts"><span class="hljs-keyword">if</span> (<span class="hljs-literal">false</span>) {
    <span class="hljs-comment">// @ts-ignore&#xFF1A;&#x65E0;&#x6CD5;&#x88AB;&#x6267;&#x884C;&#x7684;&#x4EE3;&#x7801;&#x7684;&#x9519;&#x8BEF;</span>
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;hello&quot;</span>);
}
</code></pre>
<p><code>// @ts-ignore</code>&#x6CE8;&#x91CA;&#x4F1A;&#x5FFD;&#x7565;&#x4E0B;&#x4E00;&#x884C;&#x4E2D;&#x4EA7;&#x751F;&#x7684;&#x6240;&#x6709;&#x9519;&#x8BEF;&#x3002;
&#x5EFA;&#x8BAE;&#x5B9E;&#x8DF5;&#x4E2D;&#x5728;<code>@ts-ignore</code>&#x4E4B;&#x540E;&#x6DFB;&#x52A0;&#x76F8;&#x5173;&#x63D0;&#x793A;&#xFF0C;&#x89E3;&#x91CA;&#x5FFD;&#x7565;&#x4E86;&#x4EC0;&#x4E48;&#x9519;&#x8BEF;&#x3002;</p>
<p>&#x8BF7;&#x6CE8;&#x610F;&#xFF0C;&#x8FD9;&#x4E2A;&#x6CE8;&#x91CA;&#x4EC5;&#x4F1A;&#x9690;&#x85CF;&#x62A5;&#x9519;&#xFF0C;&#x5E76;&#x4E14;&#x6211;&#x4EEC;&#x5EFA;&#x8BAE;&#x4F60;<em>&#x6781;&#x5C11;</em>&#x4F7F;&#x7528;&#x8FD9;&#x4E00;&#x6CE8;&#x91CA;&#x3002;</p>
<h2 id="&#x66F4;&#x5FEB;&#x7684;-tsc---watch">&#x66F4;&#x5FEB;&#x7684; <code>tsc --watch</code></h2>
<p>TypeScript 2.6 &#x5E26;&#x6765;&#x4E86;&#x66F4;&#x5FEB;&#x7684;<code>--watch</code>&#x5B9E;&#x73B0;&#x3002;
&#x65B0;&#x7248;&#x672C;&#x4F18;&#x5316;&#x4E86;&#x4F7F;&#x7528;ES&#x6A21;&#x5757;&#x7684;&#x4EE3;&#x7801;&#x7684;&#x751F;&#x6210;&#x548C;&#x68C0;&#x67E5;&#x3002;
&#x5728;&#x4E00;&#x4E2A;&#x6A21;&#x5757;&#x6587;&#x4EF6;&#x4E2D;&#x68C0;&#x6D4B;&#x5230;&#x7684;&#x6539;&#x53D8;<em>&#x53EA;</em>&#x4F1A;&#x4F7F;&#x6539;&#x53D8;&#x7684;&#x6A21;&#x5757;&#xFF0C;&#x4EE5;&#x53CA;&#x4F9D;&#x8D56;&#x5B83;&#x7684;&#x6587;&#x4EF6;&#x88AB;&#x91CD;&#x65B0;&#x751F;&#x6210;&#xFF0C;&#x800C;&#x4E0D;&#x518D;&#x662F;&#x6574;&#x4E2A;&#x9879;&#x76EE;&#x3002;
&#x6709;&#x5927;&#x91CF;&#x6587;&#x4EF6;&#x7684;&#x9879;&#x76EE;&#x5E94;&#x8BE5;&#x4ECE;&#x8FD9;&#x4E00;&#x6539;&#x53D8;&#x4E2D;&#x83B7;&#x76CA;&#x6700;&#x591A;&#x3002;</p>
<p>&#x8FD9;&#x4E00;&#x65B0;&#x7684;&#x5B9E;&#x73B0;&#x4E5F;&#x4E3A;tsserver&#x4E2D;&#x7684;&#x76D1;&#x542C;&#x5E26;&#x6765;&#x4E86;&#x6027;&#x80FD;&#x63D0;&#x5347;&#x3002;
&#x76D1;&#x542C;&#x903B;&#x8F91;&#x88AB;&#x5B8C;&#x5168;&#x91CD;&#x5199;&#x4EE5;&#x66F4;&#x5FEB;&#x54CD;&#x5E94;&#x6539;&#x53D8;&#x4E8B;&#x4EF6;&#x3002;</p>
<h2 id="&#x53EA;&#x5199;&#x7684;&#x5F15;&#x7528;&#x73B0;&#x5728;&#x4F1A;&#x88AB;&#x6807;&#x8BB0;&#x672A;&#x4F7F;&#x7528;">&#x53EA;&#x5199;&#x7684;&#x5F15;&#x7528;&#x73B0;&#x5728;&#x4F1A;&#x88AB;&#x6807;&#x8BB0;&#x672A;&#x4F7F;&#x7528;</h2>
<p>TypeScript 2.6&#x52A0;&#x5165;&#x4E86;&#x4FEE;&#x6B63;&#x7684;<code>--noUnusedLocals</code>&#x548C;<code>--noUnusedParameters</code><a href="https://www.typescriptlang.org/docs/handbook/compiler-options.html" target="_blank">&#x7F16;&#x8BD1;&#x9009;&#x9879;</a>&#x5B9E;&#x73B0;&#x3002;
&#x53EA;&#x88AB;&#x5199;&#x4F46;&#x4ECE;&#x6CA1;&#x6709;&#x88AB;&#x8BFB;&#x7684;&#x58F0;&#x660E;&#x73B0;&#x5728;&#x4F1A;&#x88AB;&#x6807;&#x8BB0;&#x672A;&#x4F7F;&#x7528;&#x3002;</p>
<h5 id="&#x4F8B;&#x5B50;">&#x4F8B;&#x5B50;</h5>
<p>&#x4E0B;&#x9762;<code>n</code>&#x548C;<code>m</code>&#x90FD;&#x4F1A;&#x88AB;&#x6807;&#x8BB0;&#x4E3A;&#x672A;&#x4F7F;&#x7528;&#xFF0C;&#x56E0;&#x4E3A;&#x5B83;&#x4EEC;&#x7684;&#x503C;&#x4ECE;&#x672A;&#x88AB;<em>&#x8BFB;&#x53D6;</em>&#x3002;&#x4E4B;&#x524D; TypeScript &#x53EA;&#x4F1A;&#x68C0;&#x67E5;&#x5B83;&#x4EEC;&#x7684;&#x503C;&#x662F;&#x5426;&#x88AB;<em>&#x5F15;&#x7528;</em>&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">f</span>(<span class="hljs-params">n: <span class="hljs-built_in">number</span></span>) </span>{
    n = <span class="hljs-number">0</span>;
}

<span class="hljs-keyword">class</span> C {
    <span class="hljs-keyword">private</span> m: <span class="hljs-built_in">number</span>;
    <span class="hljs-keyword">constructor</span>() {
        <span class="hljs-keyword">this</span>.m = <span class="hljs-number">0</span>;
    }
}
</code></pre>
<p>&#x53E6;&#x5916;&#x4EC5;&#x88AB;&#x81EA;&#x5DF1;&#x5185;&#x90E8;&#x8C03;&#x7528;&#x7684;&#x51FD;&#x6570;&#x4E5F;&#x4F1A;&#x88AB;&#x8BA4;&#x4E3A;&#x662F;&#x672A;&#x4F7F;&#x7528;&#x7684;&#x3002;</p>
<h5 id="&#x4F8B;&#x5B50;">&#x4F8B;&#x5B50;</h5>
<pre><code class="lang-ts"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">f</span>(<span class="hljs-params"></span>) </span>{
    f(); <span class="hljs-comment">// &#x9519;&#x8BEF;&#xFF1A;&apos;f&apos; &#x88AB;&#x58F0;&#x660E;&#xFF0C;&#x4F46;&#x5B83;&#x7684;&#x503C;&#x4ECE;&#x672A;&#x88AB;&#x4F7F;&#x7528;</span>
}
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="TypeScript 2.7.html" class="navigation navigation-prev " aria-label="Previous page: TypeScript 2.7">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="TypeScript 2.5.html" class="navigation navigation-next " aria-label="Next page: TypeScript 2.5">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"TypeScript 2.6","level":"1.7.6","depth":2,"next":{"title":"TypeScript 2.5","level":"1.7.7","depth":2,"path":"doc/release-notes/TypeScript 2.5.md","ref":"./doc/release-notes/TypeScript 2.5.md","articles":[]},"previous":{"title":"TypeScript 2.7","level":"1.7.5","depth":2,"path":"doc/release-notes/TypeScript 2.7.md","ref":"./doc/release-notes/TypeScript 2.7.md","articles":[]},"dir":"ltr"},"config":{"plugins":[],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"Patrick Zhong","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"preface.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"TypeScript Handbook","language":"zh-hans","gitbook":">3.0.0","description":"Translation of official TypeScript Handbook"},"file":{"path":"doc/release-notes/TypeScript 2.6.md","mtime":"2018-10-13T09:48:54.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-10-13T09:57:42.904Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

